﻿@model kxcxw.Data.Entities.PublichInformation
@using KXCXW.Web.CommonClass
@{
    ViewBag.Title = "Edit";
    Layout = "~/Areas/Admin/Views/Shared/_InfoLayout.cshtml";
}
<h2>
    @Html.ActionLink("信息管理", "Index") &raquo; @Html.ActionLink("修改信息", "Edit", null, new { @class = "active" })</h2>
<script src="@Url.Content("~/Scripts/jquery-1.4.4.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/createInfo_Q.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Content/datepicker/WdatePicker.js")" type="text/javascript"></script>
<script type="text/javascript">
    function Showdelete(picId) {

        document.getElementById(picId).style.display = "none";
        $.post('@Url.Action("DeletePic")',
           {
               id: picId
           }
        );
       }

       $(function(){
        $("#ddlRootCategory").change(function(){ 
            var selec = $(this).val();  //获取改变的选项值
            var url = "@Url.Action("QY")";  //参数依次类型(action,Controller,area）
            $("#ItemDeitalID").find("option").remove();  //清空
            $.getJSON(url, { 'ParentID': selec }, function (data) {  
                $.each(data, function (i, item) {
                    $("<option></option>").val(item["Value"]).text(item["Text"]).appendTo($("#ItemDeitalID"));
                });  
            });     
        });
    });
</script>
<div id="main">
    @using (Html.BeginForm("Edit", "Info", FormMethod.Post, new { name = "jNice", @class = "jNice" }))
    {
        @Html.ValidationSummary(true)
        <fieldset>
            @Html.HiddenFor(model => model.InformationID)
            @Html.HiddenFor(model => model.PriorityLevel)
            @Html.HiddenFor(model => model.PublishID)
            @Html.HiddenFor(model => model.InfoType)
            @Html.HiddenFor(model => model.Status)
            @Html.HiddenFor(model => model.PublishDate)
            @Html.HiddenFor(model => model.PictureShow)
            <div class="field">
                <div class="editor-label">
                    标 题：
                </div>
                <div class="editor-field-long">
                    @Html.EditorFor(model => model.Title)
                    @Html.ValidationMessageFor(model => model.Title)
                </div>
            </div>
            <div class="field">
                <div class="editor-label">
                    类 别：
                </div>
                <div class="editor-field">
                    @Html.DropDownList("ddlRootCategory", (SelectList)ViewBag.rootCategoryList, "请选择类别")
                </div>
                <div class="editor-field">
                    @Html.DropDownList("ItemDeitalID", (IEnumerable<SelectListItem>)ViewBag.CategoryList)
                </div>
            </div>
            <div class="field">
                <div class="editor-label">
                    促销方式：
                </div>
                <div class="editor-field">
                    @Html.DropDownListFor(model => model.PromotionType, (SelectList)ViewBag.PromotionTypeList, new { id = "ddlmothed" })
                </div>
                <div class="editor-label">
                    <span>*</span>原 价：
                </div>
                <div class="editor-field-small">
                    @Html.EditorFor(model => model.OriginalPrice)
                </div>
                <div id="zhekou">
                    <div class="editor-label">
                        <span>*</span>现 价：
                    </div>
                    <div class="editor-field-small">
                        @Html.EditorFor(model => model.PresentPrice)
                    </div>
                    <div class="editor-label">
                        <span>*</span>折 扣：
                    </div>
                    <div class="editor-field-small">
                        @Html.EditorFor(model => model.Discount)
                    </div>
                </div>
                <div id="gouzheng" style="display: none;">
                    <div class="editor-label">
                        <span>*</span>赠 品：
                    </div>
                    <div class="editor-field" style="width: 180px;">
                        @Html.EditorFor(model => model.Other)
                    </div>
                </div>
            </div>
            <div class="field">
                <div class="editor-label">
                    促销来源：
                </div>
                <div class="editor-field">
                    @Html.DropDownListFor(model => model.InfoSource, (SelectList)ViewBag.SourceList)
                </div>
                <div class="editor-label">
                    开始日期：
                </div>
                <div class="editor-field">
                    @Html.TextBox("StartDate", Model.StartDate != null ? Convert.ToDateTime(Model.StartDate).ToShortDateString() : "", new { id = "txtStartDate", @class = "Wdate", datatype = "date", onFocus = "WdatePicker({skin: 'whyGreen',isShowWeek:true,minDate:'%y-%M-%d',maxDate:'#F{$dp.$D(\\'txtEndDate\\')}'})" })
                    @Html.ValidationMessageFor(model => model.StartDate)
                </div>
                <div class="editor-label">
                    结束日期：
                </div>
                <div class="editor-field">
                    @Html.TextBox("EndDate", Model.EndDate != null ? Convert.ToDateTime(Model.EndDate).ToShortDateString() : "", new { id = "txtEndDate", @class = "Wdate", datatype = "date", onFocus = "WdatePicker({skin: 'whyGreen',isShowWeek:true,minDate:'#F{$dp.$D(\\'txtStartDate\\')}',maxDate:''})" })
                    @Html.ValidationMessageFor(model => model.EndDate)
                </div>
            </div>
            @if (Model.InfoType == 1)
            {
                @Html.Hidden("Addres", "网店无地址")
                <div class="field">
                    <div class="editor-label">
                        <span>*</span>网 址：
                    </div>
                    <div class="editor-field-long">
                        @Html.EditorFor(model => model.ShopUrl)
                        @Html.ValidationMessageFor(model => model.ShopUrl)
                    </div>
                </div>
            }
            else if (Model.InfoType == 2)
            {
                @Html.Hidden("ShopUrl", "http://www.kxcxw.com")
                <div class="field">
                    <div class="editor-label">
                        地 址：
                    </div>
                    <div class="editor-field-long">
                        @Html.EditorFor(model => model.Addres)
                        @Html.ValidationMessageFor(model => model.Addres)
                    </div>
                </div>
                <div class="field">
                    <div class="editor-label">
                        联系电话：
                    </div>
                    <div class="editor-field">
                        @Html.EditorFor(model => model.Mobile)
                        @Html.ValidationMessageFor(model => model.Mobile)
                    </div>
                    <div class="editor-label">
                        联 系 人：
                    </div>
                    <div class="editor-field">
                        @Html.EditorFor(model => model.ContactPerson)
                        @Html.ValidationMessageFor(model => model.ContactPerson)
                    </div>
                    <div class="editor-label">
                        QQ/MSN：
                    </div>
                    <div class="editor-field">
                        @Html.EditorFor(model => model.IM)
                        @Html.ValidationMessageFor(model => model.IM)
                    </div>
                </div>
            }
            <div class="field">
                <div class="editor-label">
                    推荐到：
                </div>
                <div class="editor-field">
                    @Html.DropDownList("AreaType", String.Empty)
                </div>
                <div class="editor-label">
                    浏览次数：
                </div>
                <div class="editor-field-small">
                    @Html.EditorFor(model => model.VisitsNumber)
                    @Html.ValidationMessageFor(model => model.VisitsNumber)
                </div>
            </div>
            @if (!string.IsNullOrEmpty(Model.PictureShow))
            {
                <div class="field" style="height: auto;">
                    <div class="editor-label">
                        图 片：
                    </div>
                    <div class="editor-field-long">
                        <div class="thumbnails">
                            @foreach (string filename in System.Xml.Linq.XElement.Parse(Model.PictureShow).Elements().ToList())
                            {
                                if (filename != "")
                                {
                                <div class="imgbox" id="@filename">
                                    <span>
                                        <img style="margin: 5px; opacity: 1;" src="@Url.Content(ImgHelper.ImgFoldUrl(ImgHelper.img90) + filename)"></span>
                                    @if (filename == Model.MapUrl)
                                    {
                                        <s>封面</s>
                                    }
                                </div>
                                }
                            }
                        </div>
                    </div>
                </div>
                <div class="field">
                    <div class="editor-label">
                        图片XML：
                    </div>
                    <div class="editor-field-long">
                        @Html.DisplayFor(model=>model.PictureShow)
                    </div>
                </div>
                <div class="field">
                    <div class="editor-label">
                        封面图片名：
                    </div>
                    <div class="editor-field-long">
                        @Html.EditorFor(model => model.MapUrl)
                    </div>
                </div>
            }
            <p>
                <input type="submit" value="保存修改" />
            </p>
        </fieldset>
    }
</div>
